<%@ page language="java" import="java.util.*,entity.*,Dao.*,factory.DaoFactory,Dao.Impl.*,java.sql.Date" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML>
<HEAD>
<TITLE>管理员
</TITLE>
<META http-equiv=Content-Type content="text/html;charset=utf-8" >
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Expires content=-1000>

<LINK href="/OrderMeal/css/admin.css" type="text/css" rel="stylesheet">
<link href="/OrderMeal/css/layout.css" type="text/css" rel="stylesheet">
<script language="javascript" type="text/javascript" src="/OrderMeal/My97DatePicker/WdatePicker.js"></script>
 
 <script language="javascript">
function check(form){
	if (form.start.value==""){
		alert("请选择起始时间");
		return false;
	}
	if (form.end.value==""){
		alert("请选择截止时间");
		return false;
	}

}
</script>
 
  </head>
  
  <body>
<div id="container">
<div id="header"><jsp:include page="header.jsp"></jsp:include></div>
<div id="mainContent">
<div id="sidebar"><jsp:include page="managersf.jsp"></jsp:include></div>
<div id="content">

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TR height=28>
    <TD background=/OrderMeal/Images/title_bg1.jpg>当前位置: 订单查询</TD></TR>
  <TR>
    <TD bgColor=#b1ceef height=1></TD></TR>
  <TR height=20>
    <TD background=/OrderMeal/Images/shadow_bg.jpg></TD></TR></TABLE>
  
  
  
   <center>
	<form name = "content" method = "post" action = "servlet/OrderDateQuery.do" onsubmit = "return check(content)">
	<table>
	<tr ><h1>按日期查询订单</h1></tr>
	
	 <tr> <td>开始时间：</td><td><input id="start" name="start" type="text" onClick="WdatePicker()"></td>
	      <td>截止时间：</td><td><input id="end" name="end" type="text" onClick="WdatePicker()"/></td></tr>   
	 
	 <tr ><td></td><td align="center"><input type="submit" name="submit" id="submit" value="提交"/></td>
	 <td align="center"><input type="reset" id="reset" name="reset" value="重置"/></td><td></td></tr>
	
	</table>
	</form>   
  </center>  
  
  
  <%List<Orders> list =(List) request.getAttribute("List"); %>
  
  <center>
  <table width="100%">
  <tr background=/OrderMeal/Images/shadow_bg.jpg >
    <td width = "8%"><div align = "center">订单编号</div></td>
    <td width = "8%"><div align = "center">用户编号</div></td>
    <td width = "8%"><div align = "center">用户姓名</div></td>
    <td width = "8%"><div align = "center">员工编号</div></td>
    <td width = "8%"><div align = "center">员工姓名</div></td>    
    <td width = "8%"><div align = "center">菜品编号</div></td>
    <td width = "8%"><div align = "center">菜品名称</div></td>
    <td width = "8%"><div align = "center">菜品单价</div></td>
    <td width = "8%"><div align = "center">菜品份数</div></td>
    <td width = "8%"><div align = "center">餐桌编号</div></td>
    <td width = "8%"><div align = "center">订单日期</div></td>
    <td width = "8%"><div align = "center">订单总价</div></td></tr>
    <%
    float order_sum = 0;
    int lno = 0;
    if(list!=null){    
    for(Object obj : list){
      Orders o = (Orders)obj;
      int no = o.getOrder_no();
      int wno = o.getWaiter_no();
      int uno = o.getUser_no();
      ItemDao itd = DaoFactory.getItemDao();
      FoodsDao fd = DaoFactory.getFoodsDao();
      WaitersDao wd = DaoFactory.getWaitersDao();
      Waiters w = new Waiters();
      w = wd.get(wno);
      Users u = new Users();
      UsersDao ud = DaoFactory.getUsersDao();
      u = ud.get(uno);
      float sum = 0;      
      List<Item> li = new ArrayList<Item> ();
      li = itd.getList(no);
      if(li!=null){
      	for(Object object : li){
      		Item i = (Item)object;
      		int no2 = i.getFood_no();
			Foods f = new Foods();
			f = fd.getFood(no2);
       %>
       <tr>
    <td width = "8%"><div align = "center"><%=o.getOrder_no() %></div></td>
    <td width = "8%"><div align = "center"><%=o.getUser_no() %></div></td>   
    <td width = "8%"><div align = "center"><%=u.getUser_name() %></div></td>    
    <td width = "8%"><div align = "center"><%=o.getWaiter_no() %></div></td>
    <td width = "8%"><div align = "center"><%=w.getWaiter_name() %></div></td>
    <td width = "8%"><div align = "center"><%=i.getFood_no() %></div></td>
    <td width = "8%"><div align = "center"><%=f.getFood_name() %></div></td>
    <td width = "8%"><div align = "center"><%=f.getFood_price() %></div></td>
    <td width = "8%"><div align = "center"><%=i.getMealNo() %></div></td>
    <td width = "8%"><div align = "center"><%=o.getTable_no() %></div></td>    
    <td width = "8%"><div align = "center"><%=o.getDate()%></div></td>
    <td width = "8%"><div align = "center"></div></td>
   <%
   sum = sum + f.getFood_price()* i.getMealNo();
   }
	}%>
	  </tr>
    <tr  >
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
     <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%"><div align = "center"></div></td>   
    <td width = "8%"><div align = "center"></div></td>
    <td width = "8%" background=/OrderMeal/Images/shadow_bg.jpg><div align = "center"><%=sum %></div></td>
    </tr>
	
	<%
	order_sum = order_sum + sum;
	lno++;
	}
	}%>	
  </table>
  </center>
  <table background=/OrderMeal/Images/shadow_bg.jpg width="100%">
  <tr><td width="25%"><div align = "center">订单总数：</div></td>
  <td><%=lno %></td>
  <td width="25%"><div align = "center">所有订单总额：</div></td>
  <td><%=order_sum %></td></tr></table>
  
  
  
  
  
  
    
    
 </div>
</div>

<div id="footer" align="center">版权所有    中北大学10060641  郭倩</div>

</div> 
  </body>
</html>
